/* GUI CONVERTED from rcpmb.p (converter v1.76) Fri May  3 13:21:22 2002 */
/* rcpmb.p - Release Management Customer Schedules                            */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.10.1.7 $                                                      */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.4      LAST MODIFIED: 04/13/93   BY: WUG *H341*                */
/* REVISION: 7.4      LAST MODIFIED: 05/13/94   BY: WUG *H369*                */
/* REVISION: 7.4      LAST MODIFIED: 10/19/94   BY: rxm *GN32*                */
/* REVISION: 7.4      LAST MODIFIED: 03/10/95   BY: jpm *H0BZ*                */
/* REVISION: 7.5      LAST MODIFIED: 07/17/95   BY: GWM *J049*                */
/* REVISION: 8.5      LAST MODIFIED: 04/23/96   BY: GWM *J0K1*                */
/* REVISION: 8.5      LAST MODIFIED: 04/24/96   BY: GWM *J0K9*                */
/* REVISION: 8.5      LAST MODIFIED: 05/28/96   BY: RUW *J0NW*                */
/* REVISION: 8.5      LAST MODIFIED: 06/11/96   BY: rxm *G1XQ*                */
/* REVISION: 8.6      LAST MODIFIED: 09/28/96   BY: *K003* Vinay Nayak-Sujir  */
/* REVISION: 8.6      LAST MODIFIED: 03/11/97   BY: *J1JB* Patrick Rowan      */
/* REVISION: 8.6      LAST MODIFIED: 04/15/97   BY: *K08N* Steve Goeke        */
/* REVISION: 8.6      LAST MODIFIED: 05/14/97   BY: *J1R0* Verghese Kurien    */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane          */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 10/12/98   BY: *J321* Surekha Joshi      */
/* REVISION: 8.6E     LAST MODIFIED: 08/12/99   BY: *J3KJ* Bengt Johansson    */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 07/19/00   BY: *N0GF* Mudit Mehta        */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.10.1.5     BY: Jean Miller          DATE: 03/22/01 ECO: *P008* */
/* Revision: 1.10.1.6     BY: Sandeep P.           DATE: 06/29/01 ECO: *M1CR* */
/* $Revision: 1.10.1.7 $    BY: Katie Hilbert        DATE: 04/15/02 ECO: *P03J* */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdtitle.i "2+ "}

/* UPDATE CONTROL FILE RECORDS */

define variable rcc_next_ctnr   as integer no-undo
                                label "Next Container" format ">>>>>>>9".
define variable rcc_mbol_format as character no-undo
                                label "Master Bill Document Format".
define variable rcc_auto_post   like mfc_logical no-undo
                                label "Auto Invoice Post".
define variable rcc_use_shipper like mfc_logical no-undo
                                label "Use Shipper Number for Invoice".
define variable rcc_consolidate like mfc_logical
                                label "Consolidate Invoices" no-undo.
define variable rcc_auto_inv    like mfc_logical
                                label "Print Invoice" no-undo.
define variable rcc_next_stage  as integer       label "Next Pre-Shipper"
                                                 format ">>>>>>>9" no-undo.
define variable rcc_ship_lines  as integer       label "Max Lines on a Pre-Shipper"
                                                 format ">9" no-undo.
define variable rcc_next_master as integer       label "Next Master Bill"
                                                 format ">>>>>>>9" no-undo.
define variable errorst         as logical no-undo.
define variable errornum        as integer no-undo.
define variable preship_nr_desc as character format "x(30)" no-undo.
define variable ship_nr_desc    as character format "x(30)" no-undo.
define variable master_nr_desc  as character format "x(30)" no-undo.

{sonrmdat.i}
define variable rcc_barlbl_mixed_fn  as character format "x(40)"
                                     label "Mixed Load Label" no-undo.
define variable rcc_barlbl_master_fn as character format "x(40)"
                                     label "Master Load Label" no-undo.
define variable rcc_barlbl_single_fn as character format "x(40)"
                                     label "Single Load Label" no-undo.
define variable rcc_ship_plan_pcr    like mfc_logical
                                     label "Use Ship/Plan PCR" no-undo.
define variable shc_sum_tr_item      like mfc_logical
                                     label "Sum History - Items" no-undo.
define variable shc_sum_tr_cont      like mfc_logical
                                     label "Sum History - Containers" no-undo.
define variable rcc_cum_peg          like mfc_logical
                                     label "Automatic Cum Pegging" no-undo.
define variable disp-shipping-label  as character no-undo format "x(45)".
define variable rcc_custref_val      like so_custref_val no-undo.


define buffer b_df_mstr for df_mstr.

disp-shipping-label = getTermLabelRt("SHIPPING_LABEL_TEMPLATES",45).


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
rcc_next_ctnr           colon 34
   shc_preship_nr_id       colon 34
   preship_nr_desc            at 47 no-label
   shc_ship_nr_id          colon 34
   ship_nr_desc               at 47 no-label
   shc_master_nr_id        colon 34
   master_nr_desc             at 47 no-label
   shc_format              colon 34 label "Shipper Document Format"
   df_mstr.df_desc            at 47 no-label
   rcc_mbol_format         colon 34
   b_df_mstr.df_desc          at 47 no-label
   rcc_ship_lines          colon 34
   skip(1)
   disp-shipping-label        to 50 no-label
   rcc_barlbl_mixed_fn     colon 34
   rcc_barlbl_master_fn    colon 34
   rcc_barlbl_single_fn    colon 34
   rcc_use_shipper         colon 34
   rcc_auto_post           colon 70
   rcc_consolidate         colon 34
   rcc_auto_inv            colon 70
   shc_require_inv_mov     colon 34
   shc_sum_tr_item         colon 70
   shc_trl_amts            colon 34
   shc_sum_tr_cont         colon 70
   shc_ship_rcpt           colon 34
   rcc_cum_peg             colon 70
   rcc_ship_plan_pcr       colon 34
   rcc_custref_val         colon 70
 SKIP(.4)  /*GUI*/
with frame a side-labels attr-space width 80 NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

/* INITIALIZE CONTROL RECORDS */
{gprun.i ""rcpma.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


find mfc_ctrl where mfc_field = "rcc_next_ctnr" no-lock.
rcc_next_ctnr = mfc_integer.

find first shc_ctrl exclusive-lock no-error.
if not available shc_ctrl then do:
   create shc_ctrl.
   if recid(shc_ctrl) = -1 then.
end.

find mfc_ctrl where mfc_field = "rcc_mbol_format" no-lock.
rcc_mbol_format = mfc_char.

find mfc_ctrl where mfc_field = "rcc_auto_post" no-lock.
rcc_auto_post = mfc_logical.

find mfc_ctrl where mfc_field = "rcc_use_shipper" no-lock.
rcc_use_shipper = mfc_logical.

find mfc_ctrl where mfc_field = "rcc_consolidate" no-lock.
rcc_consolidate = mfc_logical.

find mfc_ctrl where mfc_field = "rcc_auto_inv" no-lock.
rcc_auto_inv = mfc_logical.

find mfc_ctrl where mfc_field = "rcc_ship_lines" no-lock.
rcc_ship_lines = mfc_integer.

/* Get descriptions */
find df_mstr where
     df_mstr.df_format = shc_format and
     df_mstr.df_type = "1"
no-lock no-error.

find b_df_mstr where
     b_df_mstr.df_format = rcc_mbol_format and
     b_df_mstr.df_type = "2"
no-lock no-error.

run get_nrdesc
   (input shc_preship_nr_id,
    output preship_nr_desc,
    output errorst,
    output errornum).

run get_nrdesc
   (input shc_ship_nr_id,
    output ship_nr_desc,
    output errorst,
    output errornum).

run get_nrdesc
   (input shc_master_nr_id,
    output master_nr_desc,
    output errorst,
    output errornum).

find mfc_ctrl where mfc_field = "rcc_barlbl_mixed_fn" no-lock.
rcc_barlbl_mixed_fn = mfc_char.

find mfc_ctrl where mfc_field = "rcc_barlbl_master_fn" no-lock.
rcc_barlbl_master_fn = mfc_char.

find mfc_ctrl where mfc_field = "rcc_barlbl_single_fn" no-lock.
rcc_barlbl_single_fn = mfc_char.

for first mfc_ctrl
   fields (mfc_char mfc_field mfc_integer mfc_logical)
   where mfc_field = "rcc_ship_plan_pcr" no-lock:
end. /* FOR FIRST MFC_CTRL */
rcc_ship_plan_pcr    = mfc_logical.

for first mfc_ctrl
   fields(mfc_char mfc_field mfc_integer mfc_logical)
   where mfc_field = "shc_sum_tr_item" no-lock:
end.
shc_sum_tr_item = mfc_logical.

for first mfc_ctrl
   fields(mfc_char mfc_field mfc_integer mfc_logical)
   where mfc_field = "shc_sum_tr_cont" no-lock:
end.
shc_sum_tr_cont = mfc_logical.

for first mfc_ctrl
   fields(mfc_char mfc_field mfc_integer mfc_logical)
   where mfc_field = "rcc_cum_peg"
no-lock:
   rcc_cum_peg = mfc_logical.
end. /* FOR FIRST mfc_ctrl */

for first mfc_ctrl
   fields(mfc_char mfc_field mfc_integer mfc_logical)
   where mfc_field = "rcc_custref_val"
no-lock:
   rcc_custref_val = mfc_logical.
end.

display
   disp-shipping-label
   rcc_next_ctnr
   shc_preship_nr_id
   preship_nr_desc
   shc_ship_nr_id
   ship_nr_desc
   shc_master_nr_id
   master_nr_desc
   shc_format
   df_mstr.df_desc   when (available df_mstr)
   rcc_mbol_format
   b_df_mstr.df_desc when (available b_df_mstr)
   rcc_ship_lines
   rcc_barlbl_mixed_fn
   rcc_barlbl_master_fn
   rcc_barlbl_single_fn
   rcc_use_shipper
   rcc_auto_post
   rcc_consolidate
   rcc_auto_inv
   shc_require_inv_mov
   shc_trl_amts
   shc_ship_rcpt
   rcc_cum_peg
   rcc_ship_plan_pcr
   shc_sum_tr_item
   shc_sum_tr_cont
   rcc_custref_val
with frame a.

mainloop:
repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


   set
      rcc_next_ctnr
      shc_preship_nr_id
      shc_ship_nr_id
      shc_master_nr_id
      shc_format
      rcc_mbol_format
      rcc_ship_lines
      rcc_barlbl_mixed_fn
      rcc_barlbl_master_fn
      rcc_barlbl_single_fn
      rcc_use_shipper
      rcc_auto_post
      rcc_consolidate
      rcc_auto_inv
      shc_require_inv_mov
      shc_sum_tr_item
      shc_trl_amts
      shc_sum_tr_cont
      shc_ship_rcpt
      rcc_cum_peg
      rcc_ship_plan_pcr
      rcc_custref_val
   with frame a.

   /* Validate sequence ID's */
   run chk_valid
      (input shc_preship_nr_id,
       input preship_dataset,
       output errorst,
       output errornum).

   if errorst then do:
      {pxmsg.i &MSGNUM=errornum &ERRORLEVEL=3 &MSGARG1=shc_preship_nr_id}
      next-prompt shc_preship_nr_id with frame a.
      undo mainloop, retry mainloop.
   end.

   run get_nrdesc
      (input shc_preship_nr_id,
       output preship_nr_desc,
       output errorst,
       output errornum).

   run chk_valid
      (input shc_ship_nr_id,
       input shipper_dataset,
       output errorst,
       output errornum).

   if errorst then do:
      {pxmsg.i &MSGNUM=errornum &ERRORLEVEL=3 &MSGARG1=shc_ship_nr_id}
      next-prompt shc_ship_nr_id with frame a.
      undo mainloop, retry mainloop.
   end.

   run get_nrdesc
      (input shc_ship_nr_id,
       output ship_nr_desc,
       output errorst,
       output errornum).

   run chk_valid
      (input shc_master_nr_id,
       input mbill_dataset,
       output errorst,
       output errornum).

   if errorst then do:
      {pxmsg.i &MSGNUM=errornum &ERRORLEVEL=3 &MSGARG1=shc_master_nr_id}
      next-prompt shc_master_nr_id with frame a.
      undo mainloop, retry mainloop.
   end.

   run get_nrdesc
      (input shc_master_nr_id,
       output master_nr_desc,
       output errorst,
       output errornum).

   display
      preship_nr_desc
      ship_nr_desc
      master_nr_desc
   with frame a.

   if shc_format <> "" then do:
      /* Document should be a shipper ie type=1*/
      find df_mstr where
           df_mstr.df_format = shc_format and
           df_mstr.df_type = "1"
      no-lock no-error.
      if not available df_mstr then do:
         /* Document format not found */
         {pxmsg.i &MSGNUM=5900 &ERRORLEVEL=3}
         next-prompt shc_format with frame a.
         undo mainloop, retry mainloop.
      end.
      else
         display
            df_mstr.df_desc
         with frame a.
   end.
   else
      display
         "" @ df_mstr.df_desc
      with frame a.

   if rcc_mbol_format <> "" then do:
      /* Document should be a master bill ie type=2 */
      find b_df_mstr where
           b_df_mstr.df_format = rcc_mbol_format and
           b_df_mstr.df_type = "2"
      no-lock no-error.
      if not available b_df_mstr then do:
         /* Document format not found */
         {pxmsg.i &MSGNUM=5900 &ERRORLEVEL=3}
         next-prompt rcc_mbol_format with frame a.
         undo mainloop, retry mainloop.
      end.  /* if not available */
      else
         display
            b_df_mstr.df_desc
         with frame a.
   end.  /* if rcc_mbol_format */
   else
      display
         "" @ b_df_mstr.df_desc
      with frame a.

   /* Warn about blank format */
   if shc_format = "" or rcc_mbol_format = "" then do:
      /* Format is blank, document will not be printed */
      {pxmsg.i &MSGNUM=5817 &ERRORLEVEL=2}
   end.  /* if shc_format */

   if rcc_barlbl_mixed_fn = "" or search(rcc_barlbl_mixed_fn) = ?
   then do:
      /*Default Mixed Label Template does not exist */
      {pxmsg.i &MSGNUM=1733 &ERRORLEVEL=2}.
   end.

   if rcc_barlbl_master_fn = "" or search(rcc_barlbl_master_fn) = ?
   then do:
      /* Default Master Label Template does not exist */
      {pxmsg.i &MSGNUM=1734 &ERRORLEVEL=2}.
   end.

   if rcc_barlbl_single_fn = "" or search(rcc_barlbl_single_fn) = ?
   then do:
      /* Default Single Label Template does not exist */
      {pxmsg.i &MSGNUM=1735 &ERRORLEVEL=2}.
   end.

   find mfc_ctrl where mfc_field = "rcc_next_ctnr" exclusive-lock.
   mfc_integer = rcc_next_ctnr.

   find mfc_ctrl where mfc_field = "rcc_mbol_format" exclusive-lock.
   mfc_char = rcc_mbol_format.

   find mfc_ctrl where mfc_field = "rcc_auto_post" exclusive-lock.
   mfc_logical = rcc_auto_post.

   find mfc_ctrl where mfc_field = "rcc_use_shipper" exclusive-lock.
   mfc_logical = rcc_use_shipper.

   find mfc_ctrl where mfc_field = "rcc_consolidate" exclusive-lock.
   mfc_logical = rcc_consolidate.

   find mfc_ctrl where mfc_field = "rcc_auto_inv" exclusive-lock.
   mfc_logical = rcc_auto_inv.

   find mfc_ctrl where mfc_field = "rcc_ship_lines" exclusive-lock.
   mfc_integer = rcc_ship_lines.

   find mfc_ctrl where mfc_field = "rcc_barlbl_mixed_fn" exclusive-lock.
   mfc_char = rcc_barlbl_mixed_fn.

   find mfc_ctrl where mfc_field = "rcc_barlbl_master_fn" exclusive-lock.
   mfc_char = rcc_barlbl_master_fn.

   find mfc_ctrl where mfc_field = "rcc_barlbl_single_fn" exclusive-lock.
   mfc_char = rcc_barlbl_single_fn.

   find mfc_ctrl where mfc_field = "rcc_ship_plan_pcr" exclusive-lock.
   mfc_logical = rcc_ship_plan_pcr.

   find mfc_ctrl where mfc_field = "shc_sum_tr_item" exclusive-lock.
   mfc_logical = shc_sum_tr_item.

   find mfc_ctrl where mfc_field = "shc_sum_tr_cont" exclusive-lock.
   mfc_logical = shc_sum_tr_cont.

   /* FIND THE MFC_CTRL ENTRY THAT STORES THE "CUSTOMER REF
      IS CUSTOMER ITEM" AND UPDATE IT */
   find mfc_ctrl where mfc_field = "rcc_custref_val" exclusive-lock.
   mfc_logical = rcc_custref_val.

   find mfc_ctrl where mfc_field = "rcc_cum_peg" exclusive-lock.
   if available mfc_ctrl
   then
      mfc_logical = rcc_cum_peg.

end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* MAINLOOP */

/* Internal procedures for accessing NR attributes */
{gpnrseq.i}
